#ifndef _PULESLINE_
#define _PULESLINE_
#include "HardwareInfo.c"
#include <SetMotorCode0.h>
#include <GetSysTime.h>
#include <GetMotorCode.h>
#include "getAd.c"
#include <SetTraceV2BeepI2C.h>
#include <SetMotor_Code.h>
#include "lineslow1.c"

void pulesline(unsigned int plues, double k, unsigned int LR)
{
    // extern global var
    extern unsigned char g_Speed;

    unsigned long T1 = 0;
    unsigned char maxIndex = 0;
    unsigned int Speed2 = 0;
    int code = 0;
    SetMotorCode0(1);
    SetMotorCode0(2);
    
    T1 = GetSysTime();
    while ( code<plues )
    {
        if ( LR==0 )
        {
            code = GetMotorCode(1);
        }
        else
        {
            code = GetMotorCode(2);
        }
        if(code<0) code=-code;
        getAd();
        
        if(GetSysTime()-T1<20)
        lineslow1(40,30,20,10);
        else
        lineslow1(10*k,8*k,6*k,5*k);
    }
    SetTraceV2BeepI2C(_TRACEV2_1_, 1);
    SetMotor_Code(1, 1, 100);
    SetMotor_Code(2, 1, 100);
}
#endif

